package com.microservice.postservice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.microservice.postservice.entity.PostImage;
import com.microservice.postservice.mapper.PostImageMapper;
import com.microservice.postservice.service.PostImageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author leesin
 * @since 2022-05-14
 */
@Service
public class PostImageServiceImpl extends ServiceImpl<PostImageMapper, PostImage> implements PostImageService {
    @Autowired
    PostImageService postImageService;
    @Override
    public boolean addImage(PostImage postImage) {
        int insert = baseMapper.insert(postImage);
        if (insert>0){
            return true;
        }else {
            return  false;
        }
    }

    /**
     * 根据postid获得图片list
     * @param postId
     * @return
     */
    public List<PostImage> getImageList(String postId){
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("post_id",postId);
        List<PostImage> list=postImageService.list(wrapper);
        return list;
    }
}
